package com.mlamp.demo.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.mlamp.demo.data.mapper.TbGlUserMapper;
import com.mlamp.demo.data.mode.TbGlUser;

@Service
public class IndexService {
	
	@Resource
	TbGlUserMapper tbGlUserMapper;
	
	public void save(TbGlUser record){
		tbGlUserMapper.insert(record);
	}
	
	public void update(TbGlUser record){
		tbGlUserMapper.updateByPrimaryKey(record);
	}
	
	public TbGlUser findOne(String id){
		TbGlUser tbGlUser=tbGlUserMapper.selectByPrimaryKey(id);
		return tbGlUser;
	}
	
	public List<Map<String, Object>> findByParams(Map<String, Object>  params){
		List<Map<String, Object>> tbGlUsers=tbGlUserMapper.findByParams(params);
		return tbGlUsers;
	}
	
	/**
	 * 分页参数
	 * https://github.com/pagehelper/Mybatis-PageHelper/blob/4.2/wikis/UseOrderBy.md
	 * @param params
	 * @return
	 */
	public PageInfo<TbGlUser> findPage(Map<String, Object>  params){
		 PageHelper.startPage(1, 10);
		 PageHelper.orderBy("sfzh desc");
         List<TbGlUser> list = tbGlUserMapper.findPage(params);
         PageInfo<TbGlUser> page = new PageInfo<TbGlUser>(list);
         return page;
	} 


}
